;;; GNU Guix --- Functional package management for GNU
;;;
;;; Copyright © 2022 jgart <jgart@dismail.de>
;;; Copyright © 2022 Dhruvin Gandhi <contact@dhruvin.dev>
;;; Copyright © 2022 (unmatched parenthesis <paren@disroot.org>
;;;
;;; This file is not part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (guixrus packages senpai)
  #:use-module (gnu packages golang)
  #:use-module (gnu packages man)
  #:use-module ((guixrus packages common go) #:prefix rus:)
  #:use-module (guix build-system go)
  #:use-module (guix git-download)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module ((guixrus contributors) #:prefix contributor:))

(define-public senpai
  (let ((commit "859b8fdb7d433a848668c6f1a00406f107fe00e5")
        (revision "1"))
    (package
      (name "senpai")
      (version (git-version "0.0.0" revision commit))
      (source
        (origin
          (method git-fetch)
          (uri (git-reference
                 (url "https://git.sr.ht/~taiite/senpai")
                 (commit commit)))
          (file-name (git-file-name name version))
          (sha256
            (base32 "0j1dshkd6jmcvgmhxsgaxvkgp3vi52wk3f7zd604w48lnzynzdc2"))))
      (build-system go-build-system)
      (arguments
        '(#:import-path "git.sr.ht/~taiite/senpai"
          #:install-source? #f
          #:phases
          (modify-phases %standard-phases
            (replace 'build
              (lambda _
                (invoke "make" "-C" "src/git.sr.ht/~taiite/senpai")))
            (add-after 'build 'build-docs
              (lambda _
                (with-directory-excursion "src/git.sr.ht/~taiite/senpai"
                  (invoke "sh" "-c" "scdoc < doc/senpai.1.scd > doc/senpai.1")
                  (invoke "sh" "-c" "scdoc < doc/senpai.5.scd > doc/senpai.5"))))
            (replace 'install
              (lambda* (#:key outputs #:allow-other-keys)
                (let ((out (assoc-ref outputs "out")))
                  (invoke "make" "install" "-C" "src/git.sr.ht/~taiite/senpai"
                          (string-append "PREFIX=" out))))))))
      (native-inputs (list scdoc))
      (inputs
       (list go-golang-org-x-time
             go-golang-org-x-term
             go-golang-org-x-net
             go-github-com-mattn-go-runewidth
             go-git-sr-ht-emersion-go-scfg
             rus:go-github-com-delthas-tcell
             rus:go-mvdan-cc-xurls))
      (home-page "https://git.sr.ht/~taiite/senpai")
      (synopsis "An IRC client that works best with bouncers")
      (description "@code{senpai} is an IRC client that works best with bouncers. No logs are
kept, history is fetched from the server via @code{CHATHISTORY}, and networks are fetched from
the server via @code{bouncer-networks}.")
      (license license:isc)
      (properties `((maintainers . (,contributor:unmatched-paren)))))))
